package com.jishuhe.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import java.time.Duration;
import java.time.temporal.ChronoUnit;

@Component
@Data
@ConfigurationProperties(prefix = "servers")
@Validated
public class ServletConfig {
    private String ipAddress;
    @Max(value = 65535,message = "超过最大值")
    private int port;
    @DurationUnit(ChronoUnit.HOURS)
    private Duration timeout;
}
